import java.util.Stack;

/**
 * 获取元素最大的元素
 */
public class TestMax {

    static Stack<Integer> stack = new Stack<>();

    static Stack<Integer> stackMax = new Stack<>();

    public static void push(Integer a) {
        if(a == null) {
            return;
        }
        stack.push(a);
        if(stackMax.isEmpty() || a > stackMax.peek()) {
            stackMax.push(a);
        } else {
            stackMax.push(stackMax.peek());
        }
    }

    public static Integer pop() {
        if(stack.isEmpty()) {
            return null;
        }
        Integer pop = stack.pop();
        stackMax.pop();
        return pop;
    }

    public static Integer getMax() {
        return stackMax.isEmpty() ? null : stackMax.peek();
    }

    public static void main(String[] args) {
        Object ob = new Object();
        ob.equals("");

        String str = new String("");
        str.equals("");
    }
}
